
package com.jf.cloud.delivery.controller.admin;

import com.jf.cloud.common.database.dto.PageDTO;
import com.jf.cloud.common.database.vo.PageVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.delivery.dto.DeliveryCompanyDTO;
import com.jf.cloud.delivery.service.DeliveryCompanyService;
import com.jf.cloud.delivery.vo.DeliveryCompanyVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 物流公司
 *
 * @author zz
 * @date 2020-12-07 15:10:00
 */
@RestController("adminDeliveryCompanyController")
@RequestMapping("/mp/delivery_company")
@Tag(name = "物流公司")
public class DeliveryCompanyController {

    @Autowired
    private DeliveryCompanyService deliveryCompanyService;

    @GetMapping("/page")
    @Operation(summary = "分页获取物流公司列表" , description = "分页获取物流公司列表")
    public ServerResponseEntity<PageVO<DeliveryCompanyVO>> page(@Valid PageDTO pageDTO,@ParameterObject DeliveryCompanyDTO deliveryCompanyDTO) {
        PageVO<DeliveryCompanyVO> pageVO = deliveryCompanyService.page(pageDTO, deliveryCompanyDTO);
        return ServerResponseEntity.success(pageVO);
    }

    @GetMapping("/list")
    @Operation(summary = "获取物流公司列表" , description = "获取物流公司列表")
    public ServerResponseEntity<List<DeliveryCompanyVO>> list() {
        return ServerResponseEntity.success(deliveryCompanyService.list());
    }

    @GetMapping
    @Operation(summary = "根据id获取物流公司信息" , description = "根据id获取物流公司信息")
    public ServerResponseEntity<DeliveryCompanyVO> getById(@RequestParam(value = "deliveryCompanyId") Long deliveryCompanyId) {
        return ServerResponseEntity.success(deliveryCompanyService.getByDeliveryCompanyId(deliveryCompanyId));
    }

}
